package com.imooc.o2o.web.superadmin;/**
 * @package: com.imooc.o2o.web.superadmin
 * @data: 2018/8/19
 * @author: 70918
 */

import com.imooc.o2o.entity.Area;
import com.imooc.o2o.service.AreaService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author ：zglx
 * Date       ：Created in 1:37 2018/8/19
 * Description：TODO
 * version:     V1.0
 */
@Controller
@RequestMapping("/superadmin")
public class AreaController {
    Logger logger = LoggerFactory.getLogger(AreaController.class);
    @Autowired
    private AreaService areaService;

    @RequestMapping(value = "/listarea")
    @ResponseBody
    private Map<String, Object> listArea() {
        logger.info("====start===");
        long startTime = System.currentTimeMillis();
        Map<String, Object> modelMap = new HashMap<>();
        List<Area> list = new ArrayList<>();
        try {
            list = areaService.getAreaList();
            modelMap.put("rows", list);
            modelMap.put("total", list.size());
        } catch (Exception e) {
            e.printStackTrace();
            modelMap.put("success", false);
            modelMap.put("errMsg", e.toString());
        }
        logger.error("tetst error");
        long endTiem = System.currentTimeMillis();
        logger.debug("costtime:[{}time]",endTiem-startTime);
        logger.info("====end===");
        return modelMap;
    }
}
